﻿//------------------------------------------------------------------------------------------------------
// <summary>
//     The following code is allowed to be used inernally in Pfizer China only, 
//     you are not permitted neither to use the contents nor disclose it in any
//     manner to third parties.
// </summary>
// <copyright file="ConfigurationHelper.cs" company="Pfizer China">
//     Copyright (c) Pfizer China. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------------------------------

using System.Configuration;


namespace SystemFrameWork
{
    /// <summary>
    /// configuration file helper
    /// </summary>
    public class ConfigurationHelper
    {
        /// <summary>
        /// get the sql connection string from the configuration file
        /// </summary>
        public static string SqlConnectionString
        {
            get
            {
                ////return @"Data Source=.;user id=sa; pwd=123;DataBase=PASS;Min Pool Size=5;Max Pool Size=60";
                ////omit the code below just for coding home with the local data base
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.SqlConnectionString];

                ///when the invoker is not a web app
                if (string.IsNullOrEmpty(returnValue))
                {
                    return @"Data Source=bjgaspssodev03\MSSQLDEV;user id=sa; pwd=P@ssw0rd;DataBase=PASSTest;Min Pool Size=5;Max Pool Size=60";
                }
                else
                {
                    return returnValue;
                }
            }
        }

        /// <summary>
        /// get the connection time out value
        /// </summary>
        public static int ConnetionTimeOut
        {
            get
            {
                try
                {
                    return int.Parse(ConfigurationManager.AppSettings[ConstantsManager.ConnetionTimeOut]);

                }
                catch
                {
                    return 60;
                }
            }
        }

        /// <summary>
        /// the page size of web
        /// </summary>
        public static int PageSize
        {
            get
            {
                return int.Parse(ConfigurationManager.AppSettings[ConstantsManager.PageSize]);
            }
        }

        /// <summary>
        /// the file format set of the system
        /// </summary>
        public static string FileFormat
        {
            get
            {
                return ConfigurationManager.AppSettings[ConstantsManager.FileFormat].ToString();
            }
        }

        /// <summary>
        /// the graphic file format set of the system
        /// </summary>
        public static string PassGraphicFormat
        {
            get
            {
                return ConfigurationManager.AppSettings[ConstantsManager.PassGraphicFormat].ToString();
            }
        }

        public static string UnSightUrl
        {
            get
            {
                return ConfigurationManager.AppSettings[ConstantsManager.UnSightUrl].ToString();
            }
        }

        /// <summary>
        /// the upload file size
        /// </summary>
        public static int UploadFileSize
        {
            get
            {
                return int.Parse(ConfigurationManager.AppSettings[ConstantsManager.FolderSizeLimit].ToString());
            }
        }

        /// <summary>
        /// the medium file path
        /// </summary>
        public static string MediumFilePath
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.MediumFilePath];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"~\Files\TempMedium";
                }

            }
        }

        /// <summary>
        /// FolderSizeLimit
        /// </summary>
        public static string FolderSizeLimit
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.FolderSizeLimit];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return "4096000";
                }

            }
        }

        /// <summary>
        /// the medium file path for reading
        /// </summary>
        public static string MediumFilePathReading
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.MediumFilePathReading];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"~\Files\TempMedium";
                }

            }
        }

        /// <summary>
        /// the Email Template file path
        /// </summary>
        public static string EmailFilePath
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.EmailFilePath];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"~\EmailTemplate";
                }

            }
        }


        /// <summary>
        /// EmailFromAddress
        /// </summary>
        public static string EmailFromAddress
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.EmailFromAddress];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"PASS@Pfizer.com";
                }

            }
        }

        /// <summary>
        /// EmailFromName
        /// </summary>
        public static string EmailFromName
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.EmailFromName];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"PASS SYSTEM";
                }

            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static string PlayerButtonIconPath
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings[ConstantsManager.PlayerButtonIconPath];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"~\Include\_images\PlayButton.jpg";
                }

            }
        }

        /// <summary>
        /// 
        /// </summary>
        public static string FileUplodePath
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings["FileUplodePath"];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"~\Files\TempUpload";
                }
            }
        }

        /// <summary>
        /// the login interface
        /// </summary>
        public static string LoginInterface
        {
            get
            {
                string returnValue = ConfigurationManager.AppSettings["LoginInterface"];
                if (!string.IsNullOrEmpty(returnValue))
                {
                    return returnValue;
                }
                else
                {
                    return @"~/Login/PfizerStaffLogin.aspx";
                }
            }
        }

        public static string LoginOutface
        {
            get
            {
                return @"~/Login/CandidateLogin.aspx";
            }
        }
    }
}
